﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Core;

namespace NHibernateBusiness.Data
{
    public class NHibernateFactory : BaseSingletonInstance<NHibernateFactory>
    {
        private Dictionary<string, INHibernateHelper> dic = new Dictionary<string, INHibernateHelper>();
        public INHibernateHelper GetDataHandler(string key)
        {
            if (dic.ContainsKey(key))
            {
                return dic[key];
            }
            else
            {
                INHibernateHelper helper = new NHibernateHelper();
                dic.Add(key, helper);
                return helper;
            }
        }
        public INHibernateHelper GetDataHandler()
        {
            INHibernateHelper helper = new NHibernateHelper();
            return helper;
        }
        public void Dispose(string key)
        {
            if (dic.ContainsKey(key))
            {
                dic.Remove(key);
            }
        }
        public void Clear()
        {
            dic.Clear();
        }
    }
}
